﻿using System;
using System.Collections.Generic;
using System.IO;
using UnityEngine;

namespace XMainClient
{
	// Token: 0x02000E0C RID: 3596
	internal class XLevelWave
	{
		// Token: 0x0600C1D6 RID: 49622 RVA: 0x002980C4 File Offset: 0x002962C4
		protected void ParseInfo(string data)
		{
			InfoType infoType = InfoType.TypeNone;
			if (data.StartsWith("id"))
			{
				infoType = InfoType.TypeId;
			}
			else if (data.StartsWith("bi"))
			{
				infoType = InfoType.TypeBaseInfo;
			}
			else if (data.StartsWith("pw"))
			{
				infoType = InfoType.TypePreWave;
			}
			else if (data.StartsWith("ei"))
			{
				infoType = InfoType.TypeEditor;
			}
			else if (data.StartsWith("mi"))
			{
				infoType = InfoType.TypeMonsterInfo;
			}
			else if (data.StartsWith("si"))
			{
				infoType = InfoType.TypeScript;
			}
			else if (data.StartsWith("es"))
			{
				infoType = InfoType.TypeExString;
			}
			else if (data.StartsWith("st"))
			{
				infoType = InfoType.TypeSpawnType;
			}
			string text = data.Substring(3);
			switch (infoType)
			{
			case InfoType.TypeId:
				this._id = int.Parse(text);
				break;
			case InfoType.TypeBaseInfo:
			{
				string[] array = text.Split(new char[]
				{
					','
				});
				this._time = float.Parse(array[0]);
				this._loopInterval = int.Parse(array[1]);
				this._EnemyID = uint.Parse(array[2]);
				this._yRotate = int.Parse(array[5]);
				if (array.Length > 6)
				{
					this._roundRidus = float.Parse(array[6]);
				}
				if (array.Length > 7)
				{
					this._roundCount = int.Parse(array[7]);
				}
				if (array.Length > 8)
				{
					this._randomID = int.Parse(array[8]);
				}
				if (array.Length > 11)
				{
					this._repeat = bool.Parse(array[11]);
				}
				break;
			}
			case InfoType.TypePreWave:
			{
				string[] array2 = text.Split(new char[]
				{
					'|'
				});
				//bool flag13 = array2.Length != 0;
				if (array2.Length != 0)
				{
					string text2 = array2[0];
					//bool flag14 = text2.Length > 0;
					if (text2.Length > 0)
					{
						string[] array3 = text2.Split(new char[]
						{
							','
						});
						for (int i = 0; i < array3.Length; i++)
						{
							int item = 0;
							if (int.TryParse(array3[i], out item))
							{
								this._preWave.Add(item);
							}
						}
					}
				}
				//bool flag16 = array2.Length > 1;
				if (array2.Length > 1)
				{
					int num = int.Parse(array2[1]);
					this._preWavePercent = (float)num / 100f;
				}
				break;
			}
			case InfoType.TypeMonsterInfo:
			{
				string[] array4 = text.Split(new char[]
				{
					','
				});
				int key = int.Parse(array4[0]);
				float x = float.Parse(array4[1]);
				float y = float.Parse(array4[2]);
				float z = float.Parse(array4[3]);
				Vector3 pos = new Vector3(x, y, z);
				this._monsterPos.Add(key, pos);
				Vector3 rotation = new Vector3(0f, 0f, 0f);
				//bool flag17 = array4.Length > 4;
				if (array4.Length > 4)
				{
					rotation.y = float.Parse(array4[4]);
				}
				this._monsterRot.Add(key, rotation);
				break;
			}
			case InfoType.TypeScript:
			{
				string[] array5 = text.Split(new char[]
				{
					','
				});
				//bool flag18 = array5.Length != 0;
				if (array5.Length != 0)
				{
					this._levelscript = array5[0];
				}
				break;
			}
			case InfoType.TypeExString:
				this._exString = text;
				break;
			case InfoType.TypeSpawnType:
				this._spawnType = (LevelSpawnType)int.Parse(text);
				break;
			}
		}

		// Token: 0x0600C1D7 RID: 49623 RVA: 0x00298444 File Offset: 0x00296644
		public void ReadFromFile(StreamReader sr)
		{
			string text = sr.ReadLine();
			//bool flag = text != "bw";
			if (/*!flag*/text == "bw")
			{
				for (;;)
				{
					text = sr.ReadLine();
					//bool flag2 = text == "ew";
					if (text == "ew")
					{
						break;
					}
					this.ParseInfo(text);
				}
			}
		}

		// Token: 0x0600C1D8 RID: 49624 RVA: 0x00298494 File Offset: 0x00296694
		public bool IsScriptWave()
		{
			return this._levelscript != null && this._levelscript.Length > 0;
		}

		// Token: 0x0400525D RID: 21085
		public int _id;

		// Token: 0x0400525E RID: 21086
		public LevelSpawnType _spawnType;

		// Token: 0x0400525F RID: 21087
		public float _time;

		// Token: 0x04005260 RID: 21088
		public int _loopInterval;

		// Token: 0x04005261 RID: 21089
		public uint _EnemyID;

		// Token: 0x04005262 RID: 21090
		public int _randomID;

		// Token: 0x04005263 RID: 21091
		public int _yRotate;

		// Token: 0x04005264 RID: 21092
		public bool _repeat;

		// Token: 0x04005265 RID: 21093
		public string _exString;

		// Token: 0x04005266 RID: 21094
		public List<int> _preWave = new List<int>();

		// Token: 0x04005267 RID: 21095
		public float _preWavePercent;

		// Token: 0x04005268 RID: 21096
		public Dictionary<int, Vector3> _monsterPos = new Dictionary<int, Vector3>();

		// Token: 0x04005269 RID: 21097
		public Dictionary<int, Vector3> _monsterRot = new Dictionary<int, Vector3>();

		// Token: 0x0400526A RID: 21098
		public float _roundRidus;

		// Token: 0x0400526B RID: 21099
		public int _roundCount;

		// Token: 0x0400526C RID: 21100
		public string _levelscript;
	}
}
